#include <vector>
#include "tmapParser.h"


using namespace std;

class Cut_C;
class Net_C
{
	public:
		string name;
		int nline;
};
class Node_C
{
     public:
	       Node_C(int tid=0):id(tid),choose(0){}
		   
	 
   //private:
	    int id;
	    int type;
		string name;  //exist when node = input or output
		vector<Node_C*> input;
		vector<Node_C*> output;
		vector<Net_C*> inwire;
		Net_C* outwire;
		vector<Cut_C*> cut;
		int data;
		int choose;
		/* type 對照表
		  gate    type
	       buf     2
           not     0
           and     1
           nand    3
           or      4
           nor     5
           xor     6
           xnor    7
           input   8
            output  9
		
		*/
		
		
};

/*
class Library_C
{
	public:
	
	
	//private:
		vector<Node_C*> m_vnode;
		int numofinput;
		vector<int> key;


};
*/

class Cut_C
{
	public:	
		Cut_C(vector<Node_C*>,int);
		
	
		vector<Node_C*> group;
		int numofinput;
		
		vector<Node_C*> inode;
		vector<int> fout;
		Node_C* replace;
		
};

class Mapping_C
{
     public:
            Mapping_C(parser_C*);
            
            void converttoAIG();
            void topologicalsort();   
	        void passlib();//******
            void cut();
	
	
            void DFS(Gate*);
            //------------------------------------
            void test(int);
            void fixoutput(Gate*,Gate*);
            void fixinput(Gate*,Gate*);
            void setconnection(Gate*,Gate*);
	        void getGate(vector<Gate*>& p_gate) {p_gate = m_vgate;}
	        void group(int,int,int);
	        void getNode(vector<Node_C*>& p_node) {p_node=m_vnode;}
     	    
     private:
             vector<Gate*> m_vgate;
             vector<Node_C*> m_vnode;
	         int iterfordfs;
	//     Library_C *lib;
};

